package com.company.cloud.pay.modules.third.utils;

import com.company.cloud.common.exception.BusinessException;
import com.company.cloud.pay.modules.api.constant.PayStateEnum;

public class WxPayStateConvertKit {

    /**
     * 支付状态
     */
    public static PayStateEnum convertPayState(String tradeState) {
        if ("SUCCESS".equals(tradeState)) { 			// 支付成功
            return PayStateEnum.Pay_Success;
        } else if ("NOTPAY".equals(tradeState)) { 		// 未支付
            return PayStateEnum.Pay_Not;
        } else if ("CLOSED".equals(tradeState)) {		// 已关闭
            return PayStateEnum.Pay_Fail;
        } else if ("REVOKED".equals(tradeState)) {		// 已撤销（付款码支付）
            return PayStateEnum.Pay_Fail;
        } else if ("USERPAYING".equals(tradeState)) {	// 用户支付中（付款码支付）
            return PayStateEnum.Pay_Ing;
        } else if ("PAYERROR".equals(tradeState)) {		// 支付失败(其他原因，如银行返回失败)
            return PayStateEnum.Pay_Fail;
        } else if ("REFUND".equals(tradeState)) { //转入退款
            return PayStateEnum.Pay_Ing;
        } else if ("FAIL".equals(tradeState)) { //FAIL
            return PayStateEnum.Pay_Fail;
        } else {
            throw new BusinessException("++++微信支持，不支持的支付状态:" + tradeState);
        }
    }


    /**
     * 支付状态
     */
    public static PayStateEnum convertAliPayState(String tradeState) {
        if ("TRADE_SUCCESS".equals(tradeState)) { //交易支付成功
            return PayStateEnum.Pay_Success;
        } else if ("WAIT_BUYER_PAY".equals(tradeState)) { //交易创建，等待买家付款
            return PayStateEnum.Pay_Not;
        } else if ("TRADE_CLOSED".equals(tradeState)) {//未付款交易超时关闭，或支付完成后全额退款
            return PayStateEnum.Pay_Fail;
        } else if ("TRADE_FINISHED".equals(tradeState)) {//交易结束，不可退款
            return PayStateEnum.Pay_Success;
        } else if ("ACQ.TRADE_NOT_EXIST".equals(tradeState)) {//subcode: 交易不存在 :未支付
            return PayStateEnum.Pay_Not;
        } else {
            throw new BusinessException("++++支付宝支付支持，不支持的支付状态:" + tradeState);
        }

    }


    /**
     * 支付状态
     */
    public static String convertPayStateStr(String tradeState) {
        PayStateEnum state = convertPayState(tradeState);
        return state.getCode();
    }


    public static void main(String[] args) {
//		String appId="2021002128601544";
//		String serviceUrl="https://openapi.alipay.com/gateway.do";
//		String privateKey="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDFEe4w86d8nkaox/s/D3ad/nv3SFA5T1MNGBzSBU/fXUMTIq5aYg69r3yMmIGF7vdqSIzp5TIwpbxf1vYxmonWcN55C0yykqxg5QLmLtYB+bLeaxmsmxwL4GVaDUL+Rt4CGEf6XowEn02DgIf552W9piv5GnG/QNZ6qFKrT5DsN0DQsT3f1856uoSJAw9GGrdQ+MLg74iK4D6WoyVCeRELUlkjchoLoKY1hJsHcnoEH14U+jac7HMjCktBf8pw9vsBJ8BEWQj8MRA1bR/yjCUYQ/f9x0f7CQcS7monGvEckX3t4YaiuGMMfUWn22mYeE/LzqWFliTBL5KGx8cM27tRAgMBAAECggEBAIzj4sywhb98ULv+LUvKPF18QRhrZJ90bMXhxUkJby8buAaINup7TFqkiYDiz0b3r38W21ek+pr5ApHqVxzjhUQAca1MPMs2PXMQh2AVf/7ti8mj/DkAs65yAUO+U3UDKVmKDnua+LOdSIeJbq1ll8Fcefefxk6bhjsu99tuCQg2vz6m8XjRTO/NrlIOlvlaNdkpgHtcQWnbGnwH5YraIpG8Lp8bEhz1vioYFNGpvTj+vviNIx1CA0VO6JDO64TrPdkFFSa0baxqARSDjH864aoGjZ52lXsRvvscvYTUkTbEL+wZGOB4stnszyxgz4GAsoZ0OZwMvxGNZJe0sxbPpKECgYEA4d7x4t+5Imoighij/5lE0f1TMKjJDphFvWbtIcO2qIYWy6GROPoNmHWItZ10EFH4+T8eBWgJeQOFMV1VpSVz/v024UjIRneyTwBds3b0nZLTfJ1mYfnY+TaBeG3YAcN59kPD0GNLlEL1df0kcq7uoaKRZYUcmD/on36vLTCWNYUCgYEA31t+EtNCCPnRP1b1s/Xeb0IDYuBde0IkdpdjvgvhNI+C6GVQwoPYQHc0fvVnkyxEAf0Og/V3w4stYuORAUoepLPnAKQG7a1Eg3mBztZnQehgWAf7/l//3QKY2QTQbL7UrqnWWX848wI5fMONmrQqnw2LcoHuguixbT1OZ2vmQl0CgYEArG4VfJxMajBaHbUP5b2tIx3gF0KTErg+bUQY/XC6jdanqlayVavXGy+G6RbFlvvtNOHxWjE9IgwE71WQX13DOsM11TBJ7DnOfq8J2UqTnYOMPhKvKVaiREZO+o/omhgPkGfVIc3b0dh4KNXSsFZJSE2h7715weTwAmqk8runwD0CgYBqogt2gVUtY9b6HlH/MIqZIzLqqaL3jYRK+cusl49UwI8G1BfSRY+gd0igtBhWsvNk36NmbHJY8MEiTPKVYwVuLFVEgQqtveLPwdqvHLz/Qil83ZL4xmwo32yJbzryL8jp+jtTTuGpYo5/efzItusCND021cFAzkammHYt+d1cIQKBgDcVzdsO9Y5//LXnPEtrAqq4NwwcA4SwFZJr6hiYwr2zFg+36uXZqU6T4bifj8PXHywCjyxXHu0zL5NHHnGMeRNWuMW3BX3oTByPw616NrJHQvzdydEAQLfw5sZd2esDm+TJAkXX8vBOr9PR8tsBNzcr+hHP8TIYZ0bCW/Dg9orz";
//		String alipayPublicKey="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnWwlwJWLx6zbuA/jHeOU0CHBEfIRJzIaHRQ0CE/0CHIUfWK8c31btdWZAZns2iKN04CFECO+RMow0daZEi+PT3krbpkimRabJzJOHGu4t29GN8r37pybwfp7jEC6HHSwyiPqoTtYtatcon2yCHlf7N6BICCzw2UsGYA3ST/eYcfPRG4rRfGYHqSrNJZ2Nmx0XQAMidMa/M96BCxKV+z4SU/SLuFGTG7yupobtVGer8UHi+BmyghymVa0uejAXB4StgUL2mixJMMMaxbyjLDVbQ+f3uKNrawGaqUptHstp5IvkSHArLV6MAEwVIxE47oTFOLS56dKJgzZPjxMoyzp6QIDAQAB";
//		
//		
//		PayApiConfig payConfig =new PayApiConfig();
//		payConfig.setAppId(appId);
//		payConfig.setAliPrivateKey(privateKey);
//		payConfig.setAlipayPublicKey(alipayPublicKey);
//		payConfig.setDomain("https://www.artshanghaifair.com/api/shop-center");
//		
//		System.out.println(JSON.toJSONString(payConfig));

        float f = 3 / 100f;
        System.out.println(String.valueOf(f));


    }


}
